#!/usr/bin/perl -w
use warnings;
use strict;


_foreach();

#_pipe();
#forloop();
#ifelse();
#whiledo();

sub _foreach
{
	my @arr1  =  ("truong", "xuan", "thung");
	my $cnt = @arr1;
	
	#print "count = " . $count . "\n";
	my $cnt1=0;

	foreach my $temp (@arr1)
	{
		print $temp . "\n";
		
		$cnt1++;
		if($cnt1==1)
		{
			last;
		}
	}

}

sub _pipe
{
	open(FPIPE, "| ping ");
	 print  FPIPE  "127\.0\.0\.1"; 
	close(FPIPE);
}

sub forloop
{
	for(my $count=1; $count<10; $count++)
	{
		print "count = " . $count . "\n";
	}
}

sub whiledo
{
	my $mybool = 0;
	my $mycount = 0;
	while ($mybool == 0 )
	{
		print "\$mybool is still 0" . "\$mycount is ". $mycount . " \n";
		
		$mycount++;
		
		if($mycount == 5)
		{
			$mybool = 1;
			print "\$mybool is 1 \n";
		}
	}
	
}

sub ifelse
{
	print "Enter a number \n";
	my $input_one = <STDIN>;
	chop($input_one);
	print "Enter an another number \n";
	
	my $input_two = <STDIN>;
	chop($input_two);
	if ($input_one == $input_two)
	{
		print "two  inputs is equal \n";
	}
	else
	{
		print "two inputs is not equal \n";
	}
}
